package com.fanrenqiji.entity;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * Created by yanwt on 2017/1/3.
 * 家长信息表
 */

@Entity
@Data
@Table(name = "tb_parent")
@org.hibernate.annotations.Table(appliesTo = "tb_parent",comment = "家长信息表")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
@org.hibernate.annotations.Cache(region="parent", usage = CacheConcurrencyStrategy.READ_WRITE)
public class ParentEntity extends DataEntity implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    @Column(columnDefinition=("varchar(100) default null comment '家长姓名'"))
    private String name;
    @Column(columnDefinition=("varchar(20) default null comment '联系电话'"))
    private String phone;
    @Column(columnDefinition = ("varchar(200) default null comment '头像'"))
    private String portrait;
    @Column(name = "sex", columnDefinition = ("int not null comment '性别 0:女 1:男'"))
    private String sex;
    @ManyToOne
    @JoinColumn(name="semester_id",columnDefinition=("bigint(20) default null comment '学期ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private SemesterEntity semester;
    @OneToMany
    @JoinColumn(name="parent_id",columnDefinition=("bigint(20) default null comment '家长ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private List<StudentEntity> students;
    @ManyToOne
    @JoinColumn(name="we_chat_user_id",columnDefinition=("bigint(20) default null comment '微信用户ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private WeChatUserEntity weChatUser;
}
